package view;

import java.util.Scanner;

import checking.InputValidation;
import controller.ControllerForDB;

public class MenuHelperForResource {

	static InputValidation oValidation = new InputValidation();
	static ControllerForDB controller = new ControllerForDB();
	

	public  void assignResourceToTask(int taskId) {

		System.out.println("Please choose the type of resource that yo want to assign to your task;\n");
		System.out.println("1 - Assign Person  \n");
		System.out.println("2 - Assign Material\n");
		System.out.println("3 - Exit");
		
		Scanner response = new Scanner(System.in);
		int resp = response.nextInt();
		
		switch (resp) {
		case 1:
			System.out.println("All available person resource you can use;\n");
			controller.getAllPersonFromDB();
			
			System.out.println("Please enter the person id that you want to assign to your Task.\n ");
			
			Scanner personResp= new Scanner(System.in);
			int person = personResp.nextInt();
			
			controller.assignPersonToTask(taskId,person);
			
			break;
		
		case 2:
			
			System.out.println("All available material resource you can use;\n");
			controller.getAllMaterialsFromDB();

			System.out.println("Please enter the material id that you want to assign to your Task.\n ");
			
			Scanner materialResp= new Scanner(System.in);
			int material = materialResp.nextInt();
			
			controller.assignMaterialToTask(taskId,material);
			
			break;

		case 3:
			System.out.println("Thank you. Good bye!");
			break;
		
		default:
			break;
		}
	}// add resource to task ends

	public  void unassignResorceFromTask(int taskId) {
		
		System.out.println("Please choose the type of resource that yo want to unassign to your task;\n");
		System.out.println("1 - Unassign Person  \n");
		System.out.println("2 - Unassign Material\n");
		System.out.println("3 - Exit");
		
		Scanner response = new Scanner(System.in);
		int resp = response.nextInt();
		
		switch (resp) {
		case 1:
			
			System.out.println("All person resource that you have in your project;\n");
			controller.getAllPersonOfTaskFromDB(taskId);
			
			System.out.println("Please enter the person id that you want to unassign from your task;\n");
			Scanner personResp= new Scanner(System.in);
			int person = personResp.nextInt();
			
			controller.unassingPersonFromTask(taskId, person);
			
			break;
		case 2:

			System.out.println("All material resource that you have in your project;\n");
			controller.getAllMaterialsOfTaskFromDB(taskId);
			
			System.out.println("Please enter the material id that you want to unassign from your task;\n");
			Scanner materialResp= new Scanner(System.in);
			int material = materialResp.nextInt();
			
			controller.unassingMaterialFromTask(taskId, material);
			
			
			break;
		
		case 3:
			System.out.println("Thank you. Good Bye!");
			break;

		default:
			break;
		}
		

	}
	
}
